package com.showtao.front.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.showtao.front.domain.VehicleModel;
import com.showtao.front.domain.VehicleModelFeature;

@SuppressWarnings("serial")
public class VehicleModelDto implements Serializable {

    private Long id;
    private Long lineId;
    private String lineName;
    private String name;
    private String isHatchback;
    private int featuresCount;
    private Date createdAt;
    private Date updatedAt;
    private List<VehicleModelFeature> features;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getLineId() {
        return lineId;
    }

    public void setLineId(Long lineId) {
        this.lineId = lineId;
    }

    public String getLineName() {
        return lineName;
    }

    public void setLineName(String lineName) {
        this.lineName = lineName;
    }

    public String getIsHatchback() {
		return isHatchback;
	}

	public void setIsHatchback(String isHatchback) {
		this.isHatchback = isHatchback;
	}

	public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getFeaturesCount() {
        return featuresCount;
    }

    public void setFeaturesCount(int featuresCount) {
        this.featuresCount = featuresCount;
    }
    
    public List<VehicleModelFeature> getFeatures() {
		return features;
	}

	public void setFeatures(List<VehicleModelFeature> features) {
		this.features = features;
	}

	public static VehicleModelDto from(VehicleModel vm){
        VehicleModelDto dto = new VehicleModelDto();
        dto.setId(vm.getId());
        dto.setName(vm.getName());
        dto.setCreatedAt(vm.getCreatedAt());
        dto.setUpdatedAt(vm.getUpdatedAt());
        dto.setIsHatchback(vm.getIsHatchback());
        if(vm.getLine()!=null){
            dto.setLineId(vm.getLine().getId());
            dto.setLineName(vm.getLine().getName());
        }
        if(vm.getFeatures()!=null){
            dto.setFeaturesCount(vm.getFeatures().size());
            dto.setFeatures(new ArrayList<VehicleModelFeature>(vm.getFeatures()));
        }
        return dto;
    }
}
